﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autofac;

namespace RevClinic.Core
{
    /// <summary>
    /// Implementation of IHandlerProvider using Autofac container
    /// </summary>
    public class HandlerProvider : IHandlerProvider
    {
        private IComponentContext _context = null;

        public HandlerProvider(IComponentContext context)
        {
            _context = context;
        }

        public ICommandHandler<TCommand> HandlerFor<TCommand>() where TCommand : ICommand
        {
            return _context.Resolve<ICommandHandler<TCommand>>();
        }
    }
}
